//
//  BD_CustomNavigationBar.m
//  IPCamera
//
//  Created by 宣佚 on 15/5/28.
//  Copyright (c) 2015年 宣佚. All rights reserved.
//

#import "BD_CustomNavigationBar.h"
#import "UIBarButtonItem+VTSpaceItem.h"

@implementation BD_CustomNavigationBar

+(instancetype)sharedHandler
{
    static BD_CustomNavigationBar *_sharedHandler = nil;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        _sharedHandler = [[BD_CustomNavigationBar alloc] init];
    });
    return _sharedHandler;
}

-(void)BaseNavigationBar:(UIStatusBarStyle)statusBarStyle ImageName:(NSString *)ImageName
{
    [[UIApplication sharedApplication] setStatusBarStyle:statusBarStyle];
    UIImage *image = LXY_STRETCH_IMAGE([UIImage imageNamed:ImageName], UIEdgeInsetsMake(0, 1, 0, 1));
    [[UINavigationBar appearance] setBackgroundImage:image forBarMetrics:UIBarMetricsDefault];
}

-(void)BaseNavigationBarWithoutLine:(UIStatusBarStyle)statusBarStyle ImageName:(NSString *)ImageName navigationBar:(UINavigationBar *)navigationBar
{
    [[UIApplication sharedApplication] setStatusBarStyle:statusBarStyle];
    UIImage *image = LXY_STRETCH_IMAGE([UIImage imageNamed:ImageName], UIEdgeInsetsMake(0, 1, 0, 1));
    [navigationBar setBackgroundImage:image
                       forBarPosition:UIBarPositionAny
                           barMetrics:UIBarMetricsDefault];
    
    [navigationBar setShadowImage:[UIImage new]];
}

-(UILabel *)CustomNavigationTitle:(NSString *)tilte
{
    UILabel * label = [[UILabel alloc] initWithFrame:CGRectMake(5, 5, 120, 30)];
    label.font = [UIFont systemFontOfSize:15];
    label.minimumScaleFactor = 0.5;
    label.textColor = [UIColor colorWithHexString:@"0x45BD7D"];
    label.textAlignment = NSTextAlignmentCenter;
    label.backgroundColor = [UIColor clearColor];
    label.text = tilte;
    return label;
}

-(NSArray *)CustomNavigationButtons:(UIButton *)customBut
{
    UIBarButtonItem *cbar = [[UIBarButtonItem alloc] initWithCustomView:customBut];
    return [NSArray arrayWithObjects:[UIBarButtonItem vt_fixedSpaceItemWithWidth:-12], cbar, nil];
}

-(NSArray *)CustomNavigationBarButtons:(UIBarButtonItem *)customBut
{
    return [NSArray arrayWithObjects:[UIBarButtonItem vt_fixedSpaceItemWithWidth:-12], customBut, nil];
}

@end
